import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //作业1
        String name = "刘冰";
        System.out.println(name);
        int[] arrIntA = new int[20];
        int[] arrIntB = new int[10];
        int numInt;
        Random r = new Random();
        for (int i=0;i<20;i++) {
            numInt = r.nextInt(100);
            arrIntA[i] = (int) numInt;
            if (i >= 10) {
                arrIntB[i - 10] = arrIntA[i];
            }
        }
        System.out.println("随机生成20个整数放进数组A：");
        for (int j:arrIntA){
            System.out.print(j+" ");
        }
        System.out.println();
        System.out.println("数组A的后10个给B：");
        for (int j:arrIntB){
            System.out.print(j+" ");
        }
        Arrays.sort(arrIntB);
        System.out.println();
        System.out.println("排序之后的数组B：");
        for (int j:arrIntB){
            System.out.print(j+" ");
        }
        System.out.println();
        System.out.println("输入想找的数：");
        Scanner reader=new Scanner(System.in);
        int num = reader.nextInt();
        int val = Arrays.binarySearch(arrIntB, num);
        if(val>=0){
            System.out.println(num+"的下标是："+val);
        }else {
            System.out.println(num+"不在数组B中");
        }


        //作业2
        System.out.println();
        Scanner sc = new Scanner(System.in, "UTF-8");
        char[][] ts = new char[4][7];
        String str;
        System.out.println("输入诗句：");
        for (int k=0;k<ts.length;k++){
            str = sc.next();
            ts[k]= str.toCharArray();
        }
        System.out.println("\n藏头：");
        for (int q=0;q<ts.length;q++){
            for (int j=0;j<ts[q].length;j++){
                if(j==0) {
                    System.out.print(ts[q][j] + " ");
                }
            }
        }
        System.out.println("\n藏尾：");
        for (int w=0;w<ts.length;w++){
            for (int j=0;j<ts[w].length;j++){
                if(j==ts[w].length-1) {
                    System.out.print(ts[w][j] + " ");
                }
            }
        }
    }
}